import numpy as np
import matplotlib.pyplot as plt

n = 6
h = 1/n
k1 = 1.5*n
k2 = 0.5*n

x = np.linspace(0, 1, n+1)

# 计算 y = sin(k * x * pi)
y1 = np.sin(k1 * x * np.pi)
y2 = np.sin(k2 * x * np.pi)

# 绘制图像
plt.plot(x, y1, 'r', label=f'sin({k1}πx)')
plt.plot(x, y2, 'g', label=f'sin({k2}πx)')
plt.xlabel('x')
plt.ylabel('sin(kπx)')
plt.title(f'Plot of sin(kπx)')
plt.grid(True)
plt.legend()
plt.savefig("./E9_14.jpg")